package com._520it.crm.web.controller;

import com._520it.crm.domain.ClientExploitation;
import com._520it.crm.page.AjaxResult;
import com._520it.crm.page.PageResult;
import com._520it.crm.query.ClientExploitationQueryObject;
import com._520it.crm.service.IClientExploitationService;
import com._520it.crm.util.PermissionName;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/clientExploitation")
public class ClientExploitationController {
	@Autowired
	private IClientExploitationService clientExploitationService;
	@RequiresPermissions("clientExploitation:index")
	@PermissionName("客户开发列表")
	@RequestMapping("")
	public String index(){
		return "clientExploitation";
	}
	@RequiresPermissions("clientExploitation:list")
	@PermissionName("客户开发数据")
	@RequestMapping("/list")
	@ResponseBody
	public PageResult list(ClientExploitationQueryObject qo){
		PageResult result = clientExploitationService.queryPage(qo);
		return result;
	}
	@RequiresPermissions("clientExploitation:save")
	@RequestMapping("/save")
	@ResponseBody
	@PermissionName("客户开发新增")
	public AjaxResult save(ClientExploitation clientExploitation){
		AjaxResult result = null;
		try{
			clientExploitationService.insert(clientExploitation);
			result = new AjaxResult(true,"保存成功");
		}catch(Exception e){
			e.printStackTrace();
			result = new AjaxResult("保存失败,请联系管理员!");
		}
		return result;
	}
	@RequiresPermissions("clientExploitation:update")
	@PermissionName("客户开发更新")
	@RequestMapping("/update")
	@ResponseBody
	public AjaxResult update(ClientExploitation clientExploitation){
		AjaxResult result = null;
		try{
			clientExploitationService.updateByPrimaryKey(clientExploitation);
			result = new AjaxResult(true,"更新成功");
		}catch(Exception e){
			e.printStackTrace();
			result = new AjaxResult("更新失败,请联系管理员!");
		}
		return result;
	}
	@RequiresPermissions("clientExploitation:delete")
	@PermissionName("客户开发删除")
	@RequestMapping("/delete")
	@ResponseBody
	public AjaxResult delete(Long clientExploitationId){
		AjaxResult result = null;
		try{
			clientExploitationService.deleteByPrimaryKey(clientExploitationId);
			result = new AjaxResult(true,"删除成功");
		}catch(Exception e){
			e.printStackTrace();
			result = new AjaxResult("删除失败,请联系管理员!");
		}
		return result;
	}

	@RequiresPermissions("clientExploitation:executePlan")
	@PermissionName("客户开发实施")
	@RequestMapping("/executePlan")
	@ResponseBody
	public AjaxResult executePlan(ClientExploitation ce){
		AjaxResult result = null;
		try{
			clientExploitationService.executePlan(ce);
			result = new AjaxResult(true,"实施成功");
		}catch(Exception e){
			e.printStackTrace();
			result = new AjaxResult("实施失败,请联系管理员!");
		}
		return result;
	}
}
